package com.googlecode.garbagecan.clickstudy.page.form;

import com.googlecode.garbagecan.clickstudy.BorderTemplate;
import org.apache.click.control.Form;
import org.apache.click.control.Submit;
import org.apache.click.control.TextField;
import org.apache.click.util.Bindable;

public class SimpleFormPage extends BorderTemplate {
	@Bindable
	protected String title = "Simple Form";

	@Bindable
	protected Form form = new Form();

	@Bindable
	protected String msg;

	public SimpleFormPage() {
		form.add(new TextField("name", true));
		form.add(new Submit("OK"));
		form.setListener(this, "onSubmit");
	}

	public boolean onSubmit() {
		if (form.isValid()) {
			msg = "Your name is " + form.getFieldValue("name");
		}
		return true;
	}

}
